<template>
  <!-- 供应商总库 -->
  <div class="statistics-container">
    <vab-query-form>
      <vab-query-form-right-panel :span="24">
        <el-form :inline="true" :model="queryForm" @submit.native.prevent>
          <el-form-item label="">
            <el-input
              v-model.trim="queryForm.keyword"
              style="margin-right: 10px"
              placeholder="请输入姓名或手机号"
              clearable
            />
          </el-form-item>
          <el-form-item label="">
            <el-select
              v-model="queryForm.type"
              clearable
              placeholder="请选择类型"
            >
              <el-option
                v-for="item in type"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" @click="search">
              查询
            </el-button>
          </el-form-item>
          <el-form-item>
            <el-button
              type="primary"
              icon="el-icon-refresh-right"
              @click="restart"
            >
              重置
            </el-button>
          </el-form-item>
        </el-form>
      </vab-query-form-right-panel>
    </vab-query-form>

    <el-table
      v-loading="listLoading"
      :data="list"
      @selection-change="setSelectRows"
    >
      <el-table-column
        align="center"
        show-overflow-tooltip
        label="序号"
        sortable
        type="index"
      />
      <el-table-column
        align="center"
        show-overflow-tooltip
        prop="mobile"
        label="用户手机号"
      />
      <el-table-column
        align="center"
        show-overflow-tooltip
        prop="nickname"
        label="昵称"
      />
      <el-table-column align="center" show-overflow-tooltip label="头像">
        <template #default="{ row }">
          <el-image
            style="width: 60px; height: 60px"
            :src="row.logo"
            :preview-src-list="[row.logo]"
          />
        </template>
      </el-table-column>
      <el-table-column align="center" label="类型">
        <template #default="{ row }">
          {{
            row.tax_user_auth.is_auth == 1
              ? '已认证'
              : row.tax_user_auth.is_auth == 2
              ? '未认证'
              : row.tax_user_auth.is_auth == 3
              ? '虚拟认证'
              : ''
          }}
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        show-overflow-tooltip
        prop="tax_user_auth.data.mobile"
        label="认证手机号"
      />
      <el-table-column
        align="center"
        show-overflow-tooltip
        prop="tax_user_auth.data.nickname"
        label="认证姓名"
      />
      <el-table-column
        align="center"
        show-overflow-tooltip
        prop="tax_user_auth.data.bank"
        label="认证银行"
      />
      <el-table-column
        align="center"
        show-overflow-tooltip
        prop="tax_user_auth.data.bank_card"
        label="认证银行卡号"
      />
    </el-table>
    <el-pagination
      background
      :current-page="queryForm.page"
      :page-size="queryForm.list_row"
      :layout="layout"
      :total="total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script>
  import { getTaxSupplierUserLists } from '@/api/common'

  export default {
    name: 'SupplierList',
    data() {
      return {
        type: [
          {
            value: 0,
            label: '全部',
          },
          {
            value: 1,
            label: '已认证',
          },
          {
            value: 2,
            label: '未认证',
          },
          {
            value: 3,
            label: '虚拟认证',
          },
        ],
        queryForm: {
          keyword: '',
          type: '',
        },
        disabled: false,
        listLoading: false,
        list: [],
        layout: 'total, sizes, prev, pager, next, jumper',
        total: 0,
        dialogFormVisible: false,
      }
    },
    created() {
      this.getData()
    },
    methods: {
      handleDetail() {},
      //搜索
      search() {
        this.getData()
      },
      restart() {
        this.queryForm = []
        this.getData()
      },
      getData() {
        let params = {
          page: this.queryForm.page,
          limit: this.queryForm.list_row,
          search: this.queryForm.keyword,
          type: this.queryForm.type,
        }
        getTaxSupplierUserLists(params).then((data) => {
          this.list = data.data
          this.total = data.count
        })
      },
      setSelectRows() {},
      handleSizeChange(val) {
        this.queryForm.list_row = val
        this.getData()
      },
      handleCurrentChange(val) {
        this.queryForm.page = val
        this.getData()
      },
    },
  }
</script>

<style lang="scss" scoped>
  .el-button {
    font-size: 14px;
    margin-right: 20px;
  }
</style>
